<?php
namespace Part01_SimpleFactoryMode\Code2;

$numA = $_POST['numA'];
$operate = $_POST['operate'];
$numB = $_POST['numB'];
$result = '';
if (!$numA || !$numB || !$operate) {
    echo '缺少必要参数';
    die;
}

switch ($operate) {
    case '+':
        $result = $numA + $numB;
        break;
    case '-':
        $result = $numA - $numB;
        break;
    case '*':
        $result = $numA * $numB;
        break;
    case '/':
        if ($numB != 0) {
            $result = $numA / $numB;
        } else {
            echo '除数不能为0';
            die;
        }
        break;

}
echo "结果是" . $result;